using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace EquityXOI
{
    public class AuthenticationConfigManager
    {
        private static IList<AuthenticationConfigModel> lstConfig = null;
        protected AuthenticationConfigManager()
        {
            lstConfig = ConfigurationManager.GetSection("Authentication") as List<AuthenticationConfigModel>;
        }

        private static volatile AuthenticationConfigManager m_instance = null;

        public static AuthenticationConfigManager GetInstance()
        {
            if (m_instance == null)
            {
                lock (typeof(AuthenticationConfigManager))
                {
                    if (m_instance == null)
                    {
                        m_instance = new AuthenticationConfigManager();
                    }
                }
            }
            return m_instance;
        }

        public IList<AuthenticationConfigModel> GetAuthencationConfig()
        {
            return lstConfig;
        }

        public AuthenticationConfigModel GetValidAuthencationByName(string Name)
        {
            foreach (AuthenticationConfigModel mode in lstConfig)
            {
                if (mode.Name == Name && mode.Enable)
                {
                    return mode;
                }
            }
            return null;
        }

        public AuthenticationConfigModel GetAuthencationByName(string Name)
        {
            foreach (AuthenticationConfigModel mode in lstConfig)
            {
                if (mode.Name == Name)
                {
                    return mode;
                }
            }
            return null;
        }

    }
}
